package studio.raptor.extractor.nm;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import studio.raptor.extractor.common.constant.EventMetaStatus;
import studio.raptor.extractor.segment.config.EventSourceConfig;
import studio.raptor.extractor.segment.config.ExtractorConfig;
import studio.raptor.extractor.segment.config.ServerConfig;
import studio.raptor.extractor.segment.dao.EventDao;
import studio.raptor.extractor.segment.entity.EventMeta;
import studio.raptor.extractor.segment.properties.MQProperties;
import studio.raptor.extractor.segment.properties.ZKProperties;
import studio.raptor.extractor.segment.server.ExtractorServer;
import studio.raptor.extractor.segment.service.EventMetaService;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * Created by liuyong8 on 2017/7/12. 读取抽取程序配置
 */
@Component
public class NMExtractorServerInitializer implements ApplicationRunner {

  private static final Logger log = LoggerFactory.getLogger(NMExtractorServerInitializer.class);

  private static final String BIZ_NAME = "Extractor_NRM";

  @Autowired
  private ZKProperties zkProperties;

  private ServerConfig serverConfig;

  private List<EventSourceConfig> eventSourceConfigs;

  @Autowired
  private MQProperties mqProperties;

  @Autowired
  private ExtractorServer extractorServer;

  @PostConstruct
  public void init() {
    System.out.println("----------init----------");
    // TODO 先支持一种场景，在支持多种场景
    serverConfig = new ServerConfig();
    Integer kindId = 1008;
    String eventName = "so_order_construct";
    serverConfig.setKindId(kindId);
    serverConfig.setEventName(eventName);
    serverConfig.setBizName(BIZ_NAME);
    log.info("服务配置：" + serverConfig.toString());

    extractorServer.setServerConfig(serverConfig);
  }

  @Override
  public void run(ApplicationArguments args) throws Exception {

    log.info("处理需要recover的event事件");


    extractorServer.startup();

  }


}
